package Servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.omg.CORBA.PUBLIC_MEMBER;

public class RegServlet extends HttpServlet {
	public void doGet(HttpServletRequest rq,HttpServletResponse rp)
	throws ServletException,IOException{
		ServletContext application = getServletContext();
		ServletConfig config = getServletConfig();
		rp.setContentType("text/html;charset = UTF-8");
		PrintWriter out = rp.getWriter();
		HttpSession session = rq.getSession();
		//rq.setCharacterEncoding("UTF-8");
		Enumeration e = rq.getParameterNames();
		while(e.hasMoreElements()){
			String vname = (String)e.nextElement();
			String b[]=rq.getParameterValues(vname);
			if(b.length<=1)
				out.print(vname+" = "+b[0]+"<br>");
			else{
				for(int i=0;i<b.length;i++){
					out.print(vname+" = "+b[i]+"<br>");
				}
			}	
		}
	}
	
	public void doPost(HttpServletRequest rq,HttpServletResponse rp)
			throws ServletException,IOException{
		doGet(rq, rp);
	}
}